FROM maven:3-jdk-8-alpine
WORKDIR /app
COPY pom.xml ./pom.xml
RUN mvn package
COPY src ./src
RUN mvn package

ARG JAR_FILE=target/thin/root/*.jar
RUN rm -rf app.jar && mv $JAR_FILE app.jar

FROM openjdk:8-jre-alpine

COPY --from=0 /app/target/thin /app/thin
COPY --from=0 /app/app.jar /app/app.jar
RUN cp /app/app.jar /app/thin/root/app.jar
ENTRYPOINT ["java","-Dthin.root=/app/thin/root","-jar","/app/app.jar"]
